package invalidservicedependency;

import org.eclipse.emf.ecore.EObject;

import org.eclipse.viatra2.emf.incquery.validation.runtime.Constraint;
import org.eclipse.viatra2.emf.incquery.validation.runtime.ValidationUtil;
import org.eclipse.viatra2.emf.incquery.runtime.api.impl.BaseGeneratedMatcherFactory;
import invalidservicedependency.InvalidServiceDependencyMatch;
import invalidservicedependency.InvalidServiceDependencyMatcherFactory;
import invalidservicedependency.InvalidServiceDependencyMatcher;

public class InvalidServiceDependencyConstraint extends Constraint<InvalidServiceDependencyMatch> {

	private InvalidServiceDependencyMatcherFactory matcherFactory;

	public InvalidServiceDependencyConstraint() {
		matcherFactory = new InvalidServiceDependencyMatcherFactory();
	}

	@Override
	public String getMessage() {
		return "$service1.name$ business service should not depend from $service2.name$ rest service!";
	}

	@Override
	public EObject getLocationObject(InvalidServiceDependencyMatch signature) {
		Object location = signature.get("service1");
		if(location instanceof EObject){
			return (EObject) location;
		}
		return null;
	}
	
	@Override
	public int getSeverity() {
		return ValidationUtil.getSeverity("error");
	}
	
	@Override
	public BaseGeneratedMatcherFactory<InvalidServiceDependencyMatch, InvalidServiceDependencyMatcher> getMatcherFactory() {
		return matcherFactory;
	}
}
